package Access;

import DAO.SimpleAccessorFactory;
import Entities.Album;
import Entities.Composition;
import Entities.ExecutorWithInstrument;
import Entities.Group;
import Entities.LinkAlbumAndComposition;
import Entities.LinkAlbumAndSoundRecordingCompany;
import Entities.LinkExecutorWithInstrumentAndAlbum;
import Entities.LinkGroupAndAlbum;
import Entities.LinkGroupAndComposition;
import Entities.SoundRecordingCompany;
import Exceptions.InvalidEntityException;
import ExtEntities.ExtAlbum;
import ExtEntities.VeryExtAlbum;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.sql.Date;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;

/**
 *
 * @author 647_2
 */
@Stateless
public class Albums implements AlbumsRemote {
    
    public LinkedList<ExtAlbum> getAllAlbums(){
        try {
            Album album = new Album();

            ExtAlbum temp;

            LinkedList<Album> albums = SimpleAccessorFactory.createSimpleAccessor(album).select(album);
            LinkedList<ExtAlbum> ealbums = new LinkedList<ExtAlbum>();

            for (int i = 0; i < albums.size(); i++){
                temp = this.getAlbum(albums.get(i).getIDAsInt());
                ealbums.add(temp);
            }

            return ealbums;
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchFieldException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }
    
    public LinkedList<ExtAlbum> getAllAlbums(int start, int count){
        try {
            Album album = new Album();

            ExtAlbum temp;

            LinkedList<Album> albums = SimpleAccessorFactory.createSimpleAccessor(album).select(album, start, count);
            LinkedList<ExtAlbum> ealbums = new LinkedList<ExtAlbum>();

            for (int i = 0; i < albums.size(); i++){
                temp = this.getAlbum(albums.get(i).getIDAsInt());
                ealbums.add(temp);
            }

            return ealbums;
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchFieldException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }
    
    public LinkedList<ExtAlbum> getAlbumsByGroupID(int groupID, int start, int count){
        try {
            LinkGroupAndAlbum link = new LinkGroupAndAlbum(null,new Group(groupID, null, null));
            LinkedList<LinkGroupAndAlbum> links = SimpleAccessorFactory.createSimpleAccessor(link).select(link, start, count);

            LinkedList<ExtAlbum> albums = new LinkedList<ExtAlbum>();

            for (int i = 0; i < links.size(); i++){
                albums.add(this.getAlbum(links.get(i).get_album().getIDAsInt()));
            }

            return albums;

        } catch (InvalidEntityException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchFieldException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }

    public ExtAlbum getAlbum(int ID){
        try {
            Album album = new Album(ID, null, null);
            LinkedList<Album> temp = SimpleAccessorFactory.createSimpleAccessor(album).select(album);
            
            if (temp.size() > 0){

                LinkGroupAndAlbum lgaa = new LinkGroupAndAlbum(album, null);
                LinkedList<LinkGroupAndAlbum> lgaas = SimpleAccessorFactory.createSimpleAccessor(lgaa).select(lgaa);

                LinkedList<Group> groups = new LinkedList<Group>();

                for (int i = 0; i < lgaas.size(); i++){
                    groups.add(lgaas.get(i).get_group());
                }

                ExtAlbum ealbum = new ExtAlbum(ID, temp.get(0).get_name(), temp.get(0).get_editionDate(), groups);

                return ealbum;
            } else {
                return null;
            }
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchFieldException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }
    
    public VeryExtAlbum getFullAlbum(int ID){
        try {
            Album album = new Album(ID, null, null);
            LinkedList<Album> temp = SimpleAccessorFactory.createSimpleAccessor(album).select(album);
            if (temp.size() > 0){
                
                LinkAlbumAndComposition laac = new LinkAlbumAndComposition(album, null);
                LinkedList<LinkAlbumAndComposition> laacs = SimpleAccessorFactory.createSimpleAccessor(laac).select(laac);
                
                LinkedList<Composition> comps = new LinkedList<Composition>();
                
                for (int i = 0; i < laacs.size(); i++){
                    comps.add(laacs.get(i).get_composition());
                }

                LinkGroupAndAlbum lgaa = new LinkGroupAndAlbum(album, null);
                LinkedList<LinkGroupAndAlbum> lgaas = SimpleAccessorFactory.createSimpleAccessor(lgaa).select(lgaa);

                LinkedList<Group> groups = new LinkedList<Group>();

                for (int i = 0; i < lgaas.size(); i++){
                    groups.add(lgaas.get(i).get_group());
                }

                LinkAlbumAndSoundRecordingCompany laasrc = new LinkAlbumAndSoundRecordingCompany(album, null);
                LinkedList<LinkAlbumAndSoundRecordingCompany> laasrcs = SimpleAccessorFactory.createSimpleAccessor(laasrc).select(laasrc);

                LinkedList<SoundRecordingCompany> srcs = new LinkedList<SoundRecordingCompany>();

                for (int i = 0; i < laasrcs.size(); i++){
                    srcs.add(laasrcs.get(i).get_soundrecordingcompany());
                }

                LinkExecutorWithInstrumentAndAlbum lewiaa = new LinkExecutorWithInstrumentAndAlbum(null, album);
                LinkedList<LinkExecutorWithInstrumentAndAlbum> lewiaas = SimpleAccessorFactory.createSimpleAccessor(lewiaa).select(lewiaa);

                LinkedList<ExecutorWithInstrument> ewis = new LinkedList<ExecutorWithInstrument>();

                for (int i = 0; i < lewiaas.size(); i++){
                    ewis.add(lewiaas.get(i).get_executorwithinstrument());
                }
                
                VeryExtAlbum ealbum = new VeryExtAlbum(ID, temp.get(0).get_name(), temp.get(0).get_editionDate(), groups, comps, srcs, ewis);

                return ealbum;
            } else {
                return null;
            }
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchFieldException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Albums.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }

    public boolean AddAlbum(String name, Date date){
        try {
            Album album = new Album(name, date);
            return SimpleAccessorFactory.createSimpleAccessor(album).insert(album);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean UpdateAlbum(int ID, String name, Date date){
        try {
            Album album = new Album(ID, null, null);
            Album newalbum = new Album(name, date);
            return SimpleAccessorFactory.createSimpleAccessor(album).update(album, newalbum);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }


    public boolean AddGroupToAlbum(int ID, int gID){
        try {
            Group gr = new Group(gID, null, null);
            Album album = new Album(ID, null, null);
            LinkGroupAndAlbum lgaa = new LinkGroupAndAlbum(album, gr);
            return SimpleAccessorFactory.createSimpleAccessor(lgaa).insert(lgaa);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean DeleteGroupOfAlbum(int ID, int gID){
        try {
            Group gr = new Group(gID, null, null);
            Album album = new Album(ID, null, null);
            LinkGroupAndAlbum lgaa = new LinkGroupAndAlbum(album, gr);
            return SimpleAccessorFactory.createSimpleAccessor(lgaa).delete(lgaa);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

        public boolean AddRecordingToAlbum(int ID, int rID){
        try {
            SoundRecordingCompany src = new SoundRecordingCompany(rID, null, null, null, null);
            Album album = new Album(ID, null, null);
            LinkAlbumAndSoundRecordingCompany laasrc = new LinkAlbumAndSoundRecordingCompany(album, src);
            return SimpleAccessorFactory.createSimpleAccessor(laasrc).insert(laasrc);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean DeleteRecordingOfAlbum(int ID, int rID){
        try {
            SoundRecordingCompany src = new SoundRecordingCompany(rID, null, null, null, null);
            Album album = new Album(ID, null, null);
            LinkAlbumAndSoundRecordingCompany laasrc = new LinkAlbumAndSoundRecordingCompany(album, src);
            return SimpleAccessorFactory.createSimpleAccessor(laasrc).delete(laasrc);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean AddCompositionToAlbum(int ID, int cID){
        try {
            Composition comp = new Composition(cID, null, null);
            Album album = new Album(ID, null, null);
            LinkAlbumAndComposition laac = new LinkAlbumAndComposition(album, comp);
            return SimpleAccessorFactory.createSimpleAccessor(laac).insert(laac);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean DeleteCompositionOfAlbum(int ID, int cID){
        try {
            Composition comp = new Composition(cID, null, null);
            Album album = new Album(ID, null, null);
            LinkAlbumAndComposition laac = new LinkAlbumAndComposition(album, comp);
            return SimpleAccessorFactory.createSimpleAccessor(laac).delete(laac);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean DeleteAlbum(int ID){
        try {
            Album album = new Album(ID, null, null);
            return SimpleAccessorFactory.createSimpleAccessor(album).delete(album);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

        public boolean AddExecutorWithInstrumentToAlbum(int ID, int ewiID){
        try {
            ExecutorWithInstrument ewi = new ExecutorWithInstrument(ewiID, null, null);
            Album album = new Album(ID, null, null);
            LinkExecutorWithInstrumentAndAlbum lewiaa = new LinkExecutorWithInstrumentAndAlbum(ewi, album);
            return SimpleAccessorFactory.createSimpleAccessor(lewiaa).insert(lewiaa);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }

    public boolean DeleteExecutorWithInstrumentOfAlbum(int ID, int ewiID){
        try {
            ExecutorWithInstrument ewi = new ExecutorWithInstrument(ewiID, null, null);
            Album album = new Album(ID, null, null);
            LinkExecutorWithInstrumentAndAlbum lewiaa = new LinkExecutorWithInstrumentAndAlbum(ewi, album);
            return SimpleAccessorFactory.createSimpleAccessor(lewiaa).delete(lewiaa);
        } catch (InvalidEntityException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Compositions.class.getName()).log(Level.SEVERE, null, ex);
        }

        return false;
    }
}
